<!DOCTYPE html>
<html lang='zh-CN'>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <include file="Public/title"/>
    <style type="text/css">
        #container{width:500px;height:350px}
        .label{margin-left:20px;font-weight:bold;font-size:14px}
        .lng-lat{
            margin: 0 0 30px 0px;
        }
        .lng-lat .item{
            margin: 10px;
        }

    </style>
</head>

<body>
<div class="mainWrap">

    <!--标题-->
    <div class="mainWrapHeader">
        <h1 class="mainWrapTit">{$seotitle}</h1>
    </div>
    <!--标题-->

    <form action="{:U('save',array('action'=>'add'))}" method="post" class="dataForm" id="dataForm">
        <div class="mainWrapBd">
            <div class="tab-con" id="tab-works">

                <table cellpadding="0" border="0" cellspacing="0" class="stdedit">
                    <tr>
                        <th>店铺名称</th>
                        <td><input type="text" name="store_name" id="store_name" class="sys_text"/></td>
                    </tr>

                    <tr>
                        <th>店长名字</th>
                        <td><input type="text" name="manager_name" id="manager_name" class="sys_text"/></td>
                    </tr>

                    <tr>
                        <th>店铺头像</th>
                        <td>
                            <input type="text" name="headimg" id="headimg" class="sys_text sys_text50" readonly/>
                            <a href="javascript:;" onclick="getOneFile('headimg', 'image')"
                               class="btn btn_orange btn_inboxo"><span>上传</span></a>
                        </td>
                    </tr>

                    <tr>
                        <th>登录账号（手机号）</th>
                        <td><input type="text" name="mobile" id="mobile" class="sys_text"/></td>
                    </tr>

                    <tr>
                        <th>登录密码</th>
                        <td><input type="password" name="password" id="password" class="sys_text" maxlength="18"/></td>
                    </tr>

                    <!-- <tr>
                        <th>确认密码</th>
                        <td><input type="password" name="repassword" id="repassword" class="sys_text" maxlength="18" /></td>
                    </tr> -->
                    <tr>
                        <th>座机电话（选填）</th>
                        <td><input type="text" name="telephone" id="telephone" class="sys_text"/></td>
                    </tr>
                    <tr>
                        <th>所在地区:</th>
                        <td>
                            <select id="province1" name="province1" onchange="chooseProvince(this)">
                                <option value="0">请选择省</option>
                            </select>

                            <select id="city1" name="city1" onchange="chooseCity(this)">
                                <option value="0">请选择市</option>
                            </select>

                            <select id="area1" name="area1" onchange="chooseArea(this)">
                                <option value="0">请选择区</option>
                            </select>
                            <input type="hidden" id="province" name="province" value="">
                            <input type="hidden" id="city" name="city" value="">
                            <input type="hidden" id="area" name="area" value="">
                        </td>
                    </tr>
                    <tr>
                        <th>详细地址</th>
                        <td><input type="text" name="address"  class="sys_text" id="suggestId"/></td>
                    </tr>

                    <tr>
                        <th>地址</th>
                        <td>
                            <!-- <div style="margin:10px">请输入:<input type="text" id="suggestId" size="30" value="百度" style="width:300px;" type="hidden"/></div>  -->
                            <div class="lng-lat">
                                <div class="item">
                                  当前经度:
                                  <input type="text" id="jing"/>
                                </div>
                                <div class="item">
                                 当前纬度:
                                  <input type="text" id="wei" />
                                </div>
                              
                            </div>

                             
                            <div id="container"></div>
                        </td>
                    </tr>

                    <tr>
                        <th>广告位</th>
                        <td>
                            <!-- <input type="text" name="ads" id="ads" class="sys_text"/> -->
                            <?php
                                $adsInfo = M('ads')->select();
                            ?>

                            <div class="setWrap ruleWrap ruleWrapCur">
                                <div class="setWrapBody">
                                    <ul class="clearfix ruleList">
                                        <volist name="adsInfo" id="foo">
                                            <li>
                                                <label>
                                                    <input type="checkbox" name="ads[]" <if condition="in_array($foo['id'],$alrRuleids)">checked="checked"</if> value="{$foo['id']}"> {$foo['ad_name']}
                                                     <span class="ruleRules" style="display:none;">[{$foo['ad_name']}]</span>
                                                     <img src="/{$foo['filepath']}" style="width:100px;height:100px;"/>
                                                 </label>
                                            </li>
                                        </volist>
                                    </ul>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>备注</th>
                        <td><input type="text" name="remark" id="remark" class="sys_text"/></td>
                    </tr>
                </table>
            </div>
            <div class="stdeditSubmit">
                <input type="submit" class="submit" value="提 交"/> 
                <input type="button" value="返回上一页" class="reset" onclick="history.go(-1);"/>
            </div>
        </div>
    </form>
</div>
</body>
</html>
<script type="text/javascript" src="__PUBLIC__/admin/js/cityPicker.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=cAdlwxedBYGjWRTIL1IpG8omYOxfYZvW"></script>
<script type="text/javascript">
    $(function () {
        //表单验证
        $.formValidator.initConfig({
            formID: "dataForm", mode: 'AutoTip', onError: function (msg) {
                alert(msg)
            }
        });
        $("#store_name").formValidator({onShow: "", onFocus: "请输入店铺名称"}).inputValidator({
            min: 6,
            max: 60,
            onError: "店铺名称不合格"
        });
        $("#manager_name").formValidator({onShow: "", onFocus: "请输入店长名字"}).inputValidator({
            min: 2,
            max: 10,
            onError: "店长名字不合格"
        });
        $("#headimg").formValidator({onShow: "", onFocus: "请上传店铺头像"}).inputValidator({min: 1, onError: "店铺头像不能为空"});
        $("#mobile").formValidator({onShow: "", onFocus: "请输入登录手机号"}).inputValidator({
            min: 10,
            max: 12,
            onError: "登录手机号格式错误"
        });
        $("#password").formValidator({onShow: "", onFocus: "请输入登录密码"}).inputValidator({
            min: 6,
            max: 18,
            onError: "登录密码格式错误"
        });
        $("#province1").formValidator({onShow: "", onFocus: "请选择所在省份"}).inputValidator({
            min: 1,
            onError: "所在省份不能为空"
        });
        $("#city1").formValidator({onShow: "", onFocus: "请选择所在城市"}).inputValidator({
            min: 1,
            onError: "所在城市不能为空"
        });
        $("#area1").formValidator({onShow: "", onFocus: "请选择所在地区"}).inputValidator({
            min: 1,
            onError: "所在地区不能为空"
        });
        $("#address").formValidator({onShow: "", onFocus: "请输入详细地址"}).inputValidator({
            min: 6,
            max: 18,
            onError: "详细地址格式错误"
        });

        console.log($("#province").val())
        function test(val, elem) {
            return 111;
        }
    });

</script>


<script type="text/javascript">
    
    function G(id) {
        return document.getElementById(id);
    }

    var lng = document.getElementById('jing');
    var lat = document.getElementById('wei');
    var map = new BMap.Map("container");
    var point = new BMap.Point(116.3964,39.9093);
    map.centerAndZoom(point,13);
    map.enableScrollWheelZoom();
     
    var ac = new BMap.Autocomplete(    //建立一个自动完成的对象
        {"input" : "suggestId"
        ,"location" : map
    });
     
    ac.addEventListener("onhighlight", function(e) {  //鼠标放在下拉列表上的事件
        
        var str = "";
        var _value = e.fromitem.value;
        var value = "";
        if (e.fromitem.index > -1) {
            value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        }    
        str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;
        
        value = "";
        if (e.toitem.index > -1) {
            _value = e.toitem.value;
            value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        }    

    });
     
    var myValue;
    ac.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
        lng.value = '';
        lat.value = '';
        var _value = e.item.value;
        myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        //G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
        
        setPlace();
    });
     
    /*function setPlace(){// 创建地址解析器实例
        var myGeo = new BMap.Geocoder();// 将地址解析结果显示在地图上,并调整地图视野
        myGeo.getPoint(myValue, function(point){
          if (point) {
            map.centerAndZoom(point, 16);
            map.addOverlay(new BMap.Marker(point));
          }
        }, "深圳");
    };*/
     
     
    map.addEventListener('click', function (e) {
     
        lng.value = e.point.lng;
        lat.value = e.point.lat;
    });
     
     
    //定位到当前位置
    var geolocation = new BMap.Geolocation();
    geolocation.getCurrentPosition(function(r){
        if(this.getStatus() == BMAP_STATUS_SUCCESS){
            var mk = new BMap.Marker(r.point);
            map.addOverlay(mk);
            map.panTo(r.point);
            alert('您的位置：'+r.point.lng+','+r.point.lat);
        }
        else {
            alert('failed'+this.getStatus());
        }        
    });
</script>